package flc.ast;

import android.view.View;

import androidx.annotation.NonNull;

import com.stark.usersysui.lib.event.UserSysEventImpl;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.AlbumManageFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.MyFragment;
import flc.ast.fragment.PicEditFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.event.usersys.UserSysEventProxy;
import stark.common.basic.utils.StatusBarUtils;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void onHandleStatusBar() {
        super.onHandleStatusBar();
        //设置状态栏字体颜色
        StatusBarUtils.setSystemStatusTextColor(true, this);
    }

    @Override
    protected void initView() {
        super.initView();
        //需要配置用户系统时，请添加下面这行代码，不需要时，请删除
        UserSysEventProxy.getInstance().setProxy(new UserSysEventImpl(0));
        EventStatProxy.getInstance().statLaunch(this);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment = new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class, R.id.ivHome));
        listFragment.add(new FragmentViewBinder(PicEditFragment.class, R.id.ivPicEdit));
        listFragment.add(new FragmentViewBinder(AlbumManageFragment.class, R.id.ivAlbumManage));
        listFragment.add(new FragmentViewBinder(MyFragment.class, R.id.ivMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()) {
            case R.id.ivHome:
                mDataBinding.ivHome.setImageResource(R.drawable.xjdk2);
                break;
            case R.id.ivPicEdit:
                mDataBinding.ivPicEdit.setImageResource(R.drawable.xtdk2);
                break;
            case R.id.ivAlbumManage:
                mDataBinding.ivAlbumManage.setImageResource(R.drawable.xcdk2);
                break;
            case R.id.ivMy:
                mDataBinding.ivMy.setImageResource(R.drawable.wddk2);
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.xjgb2);
        mDataBinding.ivPicEdit.setImageResource(R.drawable.xtgb2);
        mDataBinding.ivAlbumManage.setImageResource(R.drawable.xcgb2);
        mDataBinding.ivMy.setImageResource(R.drawable.wdgb2);
    }


}